package shiyan4;

import java.util.Arrays;
import java.util.Scanner;

class PersonOverride{
	private String name;
	private boolean gender;
	private int age;
	
	public PersonOverride(String name,int age,boolean gender){
		this.name=name;
		this.gender=gender;
		this.age=age;
	}
	public PersonOverride(){
		this("default",1,true);
	}
	public String toString(){
		return name+"-"+age+"-"+gender;
	}
	public boolean equals(PersonOverride e){
		if((this.name.equals(e.name))&&(this.age==e.age)&&(this.gender==e.gender))
			return true;
		else
			return false;
	}
	
}
public class Sy42 {

	public static void main(String[] args) {
		Scanner input=new Scanner(System.in);
		int n1=input.nextInt();
		PersonOverride[]person1=new PersonOverride[n1];
		for(int i=0;i<person1.length;i++)
			person1[i]=new PersonOverride();
        int n2=input.nextInt();
        int n=0;
        PersonOverride[]person2=new PersonOverride[n2];
        for(int i=0;i<n2;i++,n++){
        	PersonOverride p=new PersonOverride(input.next(),input.nextInt(),input.nextBoolean());
        	person2[n]=p;
        		for(int k=n-1;k>=0;k--){
        			if(person2[n].equals(person2[k])){
        				person2[n]=null;
        				n--;
        				break;
        			}
        		}
        }
        for(int a=0;a<n1;a++)
        	System.out.println(person1[a]);
        for(int b=0;b<n;b++)
        	System.out.println(person2[b]);
        System.out.println(n);
        System.out.println(Arrays.toString(PersonOverride.class.getConstructors()));
	}
}
